package com.woniu.controller.operation;

import com.woniu.controller.BaseController;
import com.woniu.entity.Result;
import com.woniu.pojo.Car;
import com.woniu.pojo.Order;
import com.woniu.pojo.User;
import com.woniu.service.IOrderService;
import com.woniu.vo.OrderSeachByIdReturnVo;
import com.woniu.vo.OrderUpdateReturnVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.List;

@RestController
@RequestMapping("/inspect")
@Api(tags = "巡检员业务管理")
public class InspectorController extends BaseController {

    @Autowired
    private IOrderService orderService;

    @ApiOperation("巡检员现场取证")
    @PostMapping("/{orderId}/{num}/{userPhone}")
    public Result searchOrder(
            @PathVariable long orderId,
            @PathVariable String num,
            @PathVariable String userPhone,
            @RequestBody List<String> orderImageList
            ){
        OrderUpdateReturnVo orderUpdateReturnVo = orderService.updateOrderById(orderId, num, userPhone, orderImageList);
        return toDataResult(orderUpdateReturnVo,"订单更新成功");
    }

    @ApiOperation("巡检员客户端查询有无需要处理订单")
    @GetMapping("/patrol/{patrolId}/{status}")
    public Result searchRequireOrder(
            @PathVariable String status,
            @PathVariable long patrolId){
        List<OrderSeachByIdReturnVo> orderList =  orderService.searchByStatus(patrolId, status);
        return toDataResult(orderList);
    }

    @ApiOperation("巡检员现场收费")
    @PostMapping("/order/{orderId}/{money}/{payWay}/{status}")
    public Result nowCharge(
            @PathVariable long orderId,
            @PathVariable BigDecimal money,
            @PathVariable String payWay,
            @PathVariable String status){
        Boolean flag = orderService.updateStatus(orderId,money,payWay,status);
        return toDataResult(flag,"收款成功");
    }
}
